package cluster;
import java.io.IOException;

import com.rabbitmq.client.Channel;  
import com.rabbitmq.client.Connection;  
import com.rabbitmq.client.ConnectionFactory;  
import com.rabbitmq.client.ConsumerCancelledException;
import com.rabbitmq.client.QueueingConsumer; 
import com.rabbitmq.client.ShutdownSignalException;
import static def.Comdef.*;
public class Reqv3 { 
//	 private final static String QUEUE_NAME = "SHARE_Q0";
	 private final static String HOST = _CLUSTER_HOST_NAME_03;
	/**
	 * @param args
	 * @throws IOException 
	 * @throws InterruptedException 
	 * @throws ConsumerCancelledException 
	 * @throws ShutdownSignalException 
	 */
	public static void main(String[] args) throws Exception {
		ConnectionFactory factory = new ConnectionFactory();  
        factory.setHost(HOST);
        Connection connection = factory.newConnection();  
        Channel channel = connection.createChannel();  
  
        channel.queueDeclare(_CLUSTER_TEST_QUEUE_NAME, false, false, false, null);  
        System.out.println(" [*] Waiting for messages. To exit press CTRL+C");  
  
        QueueingConsumer consumer = new QueueingConsumer(channel);  
        channel.basicConsume(_CLUSTER_TEST_QUEUE_NAME, true, consumer);  
  
        while (true) {  
            QueueingConsumer.Delivery delivery = consumer.nextDelivery();  
            String message = new String(delivery.getBody());  
            System.out.println(HOST+" [x] Received '" + message + "'");  
        }  

	}

}
